package com.example.common.validation;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class StringEnumValidator implements ConstraintValidator<StringEnum, String> {

    String[] range = {};

    @Override
    public void initialize(StringEnum arg0) {
        this.range = arg0.range();
    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext arg1) {
        for (String i : range) {
            if (value.equals(i)) {
                return true;
            }
        }
        return false;
    }

}
